<template>
  <div>
    <f-table ref="table" size="small" rowKey="paymentId" :showSetting="true" setting-key='payment3'  :tableColumns="columns" :scroll="{x:true}" :multiple="false"
             :operator="operator" :params="queryParam" :api="api.payment" handler="paymentFinishPageListHandler">
         <span slot="amountType" slot-scope="text, record, index">
            <a-tag color="#2db7f5" v-if="text=='SupplierBond'">垫付款</a-tag>
            <a-tag color="#f50" v-if="text=='CbReturn'">退市场保证金</a-tag>
            <a-tag color="#108ee9" v-if="text=='Invoice'">开票税金</a-tag>
            <a-tag color="#87d068" v-if="text=='Settle'">市场结算</a-tag>
            <a-tag color="#87d068" v-if="text=='DrugsPlan'">药品采购</a-tag>
        </span>
      <span slot="action" slot-scope="text, record">
          <template>
              <a href="javascript:;" @click="$refs['orderInfoDrawer'].showDrawer(record)"
                 v-if="record.amountType=='SupplierBond'">查看</a>
              <a href="javascript:;" @click="$refs['invoice'].showDrawer(record,'form2')"
                 v-if="record.amountType=='Invoice'">查看</a>
              <a href="javascript:;" @click="$refs['settle'].showDrawer(record,'form2')"
                 v-if="record.amountType=='Settle'">查看</a>
             <a href="javascript:;" @click="$refs['cbreturn'].showDrawer(record,'form2')"
                v-if="record.amountType=='CbReturn'">查看</a>
              <a-divider type="vertical" v-if='record.processInstanceId'/>
             <a href="javascript:;" @click="processImg(record)" v-if='record.processInstanceId'>审批进度</a>
          </template>
        </span>
    </f-table>
    <process-image ref="processImg" v-if="processImageVisible" :visible.sync="processImageVisible"
                   :processInstanceId="processInstanceId"></process-image>
    <order-supplier-bond-drawer ref="osbd"></order-supplier-bond-drawer>
    <invoice-drawer ref="invoice"></invoice-drawer>
    <settle-drawer ref="settle"></settle-drawer>
    <cbreturn-drawer ref="cbreturn"></cbreturn-drawer>
    <order-info-drawer ref="orderInfoDrawer"></order-info-drawer>
  </div>
</template>
<script>

  import api from './../js/api'
  import ProcessImage from '../../process/process_image'
  import OrderSupplierBondDrawer from '../../../business/order/supplierbond/supplierbond_drawer'
  import InvoiceDrawer from '../../../business/order/invoice/invoice_drawer'
  import SettleDrawer from '../../../business/order/settle/settle_drawer'
  import CbreturnDrawer from '../../../business/order/cbreturn/cbreturn_drawer'
  import OrderInfoDrawer from '../../../business/order/order_info_drawer'

  export default {
    name: 'TableList',
    components: {
      OrderInfoDrawer,
      InvoiceDrawer,
      OrderSupplierBondDrawer,
      ProcessImage,
      SettleDrawer,
      CbreturnDrawer
    },
    data() {
      let me = this
      //操作按钮
      let operator = []

      return {
        api: Object.assign(api, this.api),
        //列表初始化查询参数
        queryParam: { paymentState: 2 },
        processInstanceId: '',
        processImageVisible: false,
        // 表头
        columns: [
          {
            title: '#',
            width: '60px',
            align: 'center',
            fixed: 'left',
            customRender: (text, record, index) => index + 1
          },
          {
            title: '操作',
            align: 'center',
            width: '150px',
            fixed: 'left',
            scopedSlots: { customRender: 'action' }
          },
          {
            title: '票号',
            align: 'center',
            fixed: 'left',
            width: '150px',
            dataIndex: 'paymentNo'
          },
          {
            title: '单据类型',
            align: 'center',
            width: '150px',
            dataIndex: 'amountType',
            scopedSlots: { customRender: 'amountType' },
            filters: [
              {
                text: '垫付款',
                value: 'SupplierBond',
              },
              {
                text: '市场结算',
                value: 'Settle',
              },
              {
                text: '退保证金',
                value: 'CbReturn',
              },
              {
                text: '开票税金',
                value: 'Invoice',
              },
              {
                text: '药品采购',
                value: 'DrugsPlan',
              }
            ],
            filterMultiple: false
          },
          {
            title: '收款单位',
            align: 'center',
            width: '200px',
            ellipsis: true,
            dataIndex: 'deptManagerName'
          },
          {
            title: '收款人',
            align: 'center',
            width: '150px',
            ellipsis: true,
            dataIndex: 'saleManName'
          },
          {
            title: '部门',
            align: 'center',
            width: '120px',
            dataIndex: 'deptName'
          },
          {
            title: '制单人',
            align: 'center',
            width: '120px',
            dataIndex: 'nickName'
          },
          {
            title: '申请日期',
            align: 'center',
            width: '130px',
            dataIndex: 'amountDate'
          },
          {
            title: '支付金额',
            align: 'center',
            width: '120px',
            dataIndex: 'amount'
          },
          {
            title: '支付人',
            align: 'center',
            width: '120px',
            dataIndex: 'payUserName'
          },
          {
            title: '支付日期',
            align: 'center',
            width: '120px',
            dataIndex: 'payDate'
          }
        ],
        operator: operator
      }
    },
    created() {

    },
    methods: {
      onLoad() {
        this.$refs.table.refresh()
      },
      processImg(task) {
        this.processInstanceId = task.processInstanceId
        this.processImageVisible = true
      },
      /**
       * 查询事件
       * @param searchParams
       */
      searchTable(searchParams) {
        this.queryParam = Object.assign(this.queryParam, searchParams)
        this.$refs.table.refresh(true, searchParams)
      }
    }
  }
</script>
